﻿using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Mirror;

namespace MrPP.SerriedCabinet
{

    /*
    public abstract class  WindowModelListener: NetworkBehaviour
    {
        public abstract void onState(WindowModel.State oldValue, WindowModel.State newValue);
        public abstract void onSelected(int oldValue, int newValue);

        
    }
    */

    public class WindowModel : NetworkBehaviour { 

       // [SerializeField]
       // private List<WindowModelListener> _listeners = new List<WindowModelListener>();
        public enum State
        {
            None,
            Start,
            Main,
        }
       

        [SyncVar(hook ="doState")]
        private State state_ = State.None;

        public State state {
            get {
                return state_;
            }
            set {
                state_ = value;
            }
        
        }
        public void doState(State oldValue, State newValue) {
            //state = val;
            onState?.Invoke(oldValue, newValue);
        }
        public Action<State, State> onState
        {
            get;
            set;
        }


        [SyncVar(hook = "doSelected")]
        private int selected_ = -1;


        public int selected
        {
            get
            {
                return selected_;
            }
            set
            {
                selected_ = value;
            }

        }
        public void doSelected(int oldValue, int newValue)
        {

            onSelected?.Invoke(oldValue, newValue);
           // selected = val;
        }

        public Action<int, int> onSelected {
            get;
            set;
        }
    }
}